package dto

import (
	"jtvss/api/system/model"
	"jtvss/pkg/orm"
)

// UserPage 查询页
type Where struct {
	orm.DbPage
	KeyWord   string `form.:"keyWord"`
	PostName  string `form.:"postName"` //
	PostCode  string `form.:"postCode"` //
	Status    string `form.:"status"`
	MenuName  string `form.:"menuName"`  // 菜单名称
	DictType  string `form.:"dictType"`  // 字典名称
	DictLabel string `form.:"dictLabel"` // 字典标签

	CreatedBy string `form.:"-"`
}

func (o *Where) DbModelWhere(v interface{}) *orm.DbWhere {
	w := o.DbWhere()
	switch v.(type) {
	case *model.User:
		w.Equal("created_by", o.CreatedBy)
	case *model.Menu:
		w.Like("title", o.MenuName)
	case *model.Role:
		w.Equal("created_by", o.CreatedBy)
	}
	return w.Model(v)
}
